package com.gw.smscheck.controller.business.comefrom;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.gw.smscheck.entity.business.comefrom.JzfdVisitorTopFrom;
import com.gw.smscheck.service.business.comefrom.JzfdVisitorTopFromService;
import com.gw.smscheck.util.ResultConversion;
import com.gw.smscheck.util.ResultObj;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Api(description="【人流来源分布接口】")
@Controller
@RequestMapping("/visitorFromController")
public class JzfdVisitorTopFromController {
    @Autowired
    private JzfdVisitorTopFromService visitorTopFromService;

    /**
     * 查询所有
     *
     * @return
     */
    @RequestMapping(value = "/findAll", method = { RequestMethod.POST})
    @ResponseBody
    @ApiOperation(value="查询所有", notes="查询所有")
    public String findAll() {
        List<JzfdVisitorTopFrom> list = visitorTopFromService.findAll();
        return JSON.toJSONString(list);
    }

    /**
     * 分页查询
     * @param dto
     * @return
     */
    @RequestMapping(value = "/pageSelect", method = { RequestMethod.POST })
    @ResponseBody
    @ApiOperation(value="分页查询", notes="分页查询")
    public String pageSelect(JzfdVisitorTopFrom dto) {
        PageInfo<JzfdVisitorTopFrom> pageInfo = visitorTopFromService.pageSelect(dto);
        return ResultConversion.ToEasyUIDataGrid(pageInfo).toJSONString();
    }

    @RequestMapping(value = "/findCurrent", method = { RequestMethod.POST})
    @ResponseBody
    @ApiOperation(value="通过条件获取当前数据", notes="通过条件获取当前数据")
    public String findCurrent(JzfdVisitorTopFrom dto) {
        List<JzfdVisitorTopFrom> res = visitorTopFromService.findCurrent(dto);
        return ResultObj.successResultObj(res);
    }

    @RequestMapping(value = "/findByModal", method = { RequestMethod.POST})
    @ResponseBody
    @ApiOperation(value="通过条件获取数据", notes="通过条件获取数据")
    public String findByModal(JzfdVisitorTopFrom dto) {
        List<JzfdVisitorTopFrom> res = visitorTopFromService.findByModal(dto);
        return ResultObj.successResultObj(res);
    }
}
